'''
Created on 2013-11-14

@author: Administrator
'''

import threading
import logging.config

class Logger(object):
    
    _lock = threading.RLock()
    
    def __init__(self):
        self.log = None
    
    @classmethod
    def instance(cls):
        Logger._lock.acquire()
        
        if not hasattr(cls,'_instance'):
            _instance = cls()
            
        return _instance
        
        Logger._lock.release()
        
    def init(self,log_config_file,logger_name):
        logging.config.fileConfig(log_config_file)
        self.log = logging.getLogger(logger_name)
    
    def debug(self,msg):
        self.log.debug(msg)
        
    def error(self,msg):
        self.log.error(msg)
    
    def info(self,msg):
        self.log.info(msg)
